<?php

namespace Cmd\user;

use EasyWeChat\Kernel\Messages\News;
use EasyWeChat\Kernel\Messages\NewsItem;
use Douyin\douyin as Dy;

class douyin
{
    /**
     * 抖音命令入口
     *
     * @param [type] $message
     * @return void
     */
    public function douyin($message)
    {
        $result = Dy::original_video($message);
        if ($result['status'] === 0) {
            return $result['msg'] . ' <a href="https://mp.weixin.qq.com/s/LXdz94PKmjh4ruq4x9pDzg">查看帮助</a>';
        }
        return new News([
            new NewsItem([
                'title'       => '#DouYin | ' . $result['data']['title'],
                'description' => '感谢使用#ImgHelper#抖音去水印功能，么么哒~',
                'url'         => request()->domain() . '/douyin/index?video=' . urlencode($result['data']['video']) . '&music=' . urlencode($result['data']['music']) . '&title=' . urlencode($result['data']['title']) . '&img=' . $result['data']['img'],
                'image'       => $result['data']['img']
            ])
        ]);
    }
}
